WPS Office.apk(点击下载) / frq.java


package defpackage;

import cn.wps.moffice.main.cloud.storage.core.service.internal.weiyun.bean.WYToken;
import cn.wps.util.JSONUtil;
import com.facebook.ads.AudienceNetworkActivity;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;

/* renamed from: frq  reason: default package */
public final class frq {
    public frr goi = new frr();

    public final WYToken a(WYToken wYToken) throws IOException {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("Authorization", "bear " + wYToken.accessToken);
        WYToken wYToken2 = (WYToken) JSONUtil.instance(this.goi.a("https://user.weiyun.com/twoa/v1/auth/refresh_token?client_id=iciY14xT8lJF0SrlfvIhuTD36VeOkm9R&client_secret=26gJq9sDVHHxVUrAJy0COQ196v0EVXaW&refresh_token=" + wYToken.refreshToken, hashMap), WYToken.class);
        if (wYToken2 == null) {
            return null;
        }
        if (wYToken2.errCode <= 0) {
            return wYToken2;
        }
        throw new IOException(wYToken2.errMsg);
    }

    public final frn a(WYToken wYToken, String str) throws IOException, fte {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("Authorization", "bear " + wYToken.accessToken);
        frn frn = (frn) JSONUtil.instance(this.goi.a("https://user.weiyun.com/twoa/v1/files/" + str, hashMap), frn.class);
        if (1020 == frn.errCode) {
            throw new fte(-2);
        } else if (frn.errCode <= 0) {
            return frn;
        } else {
            throw new IOException(frn.errMsg);
        }
    }

    public final InputStream a(WYToken wYToken, String str, long j) throws IOException {
        HashMap hashMap = new HashMap();
        hashMap.put("Authorization", "bear " + wYToken.accessToken);
        hashMap.put("Range", "0-" + j);
        frr frr = this.goi;
        HttpGet httpGet = new HttpGet("https://user.weiyun.com/twoa/v1/files/" + str + "/download");
        frr.a((HttpUriRequest) httpGet, (Map<String, String>) hashMap);
        return frr.bSN.execute(httpGet).getEntity().getContent();
    }

    public final void a(WYToken wYToken, String str, File file) throws IOException {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("Authorization", "bear " + wYToken.accessToken);
        this.goi.a("https://user.weiyun.com/twoa/v1/files/" + str + "/update", hashMap, file);
    }

    public final void a(WYToken wYToken, String str, String str2, File file) throws IOException {
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("Authorization", "bear " + wYToken.accessToken);
        this.goi.a(("https://user.weiyun.com/twoa/v1/dirs/" + str + "/simple_upload") + "?filename=" + URLEncoder.encode(str2, AudienceNetworkActivity.WEBVIEW_ENCODING), hashMap, file);
    }

    public final WYToken te(String str) throws IOException {
        WYToken wYToken = (WYToken) JSONUtil.instance(this.goi.a("https://user.weiyun.com/twoa/v1/auth/token?client_id=iciY14xT8lJF0SrlfvIhuTD36VeOkm9R&client_secret=26gJq9sDVHHxVUrAJy0COQ196v0EVXaW&grant_type=authorization_code&code=" + str, (HashMap<String, String>) null), WYToken.class);
        if (wYToken.errCode <= 0) {
            return wYToken;
        }
        throw new IOException(wYToken.errMsg);
    }
}